<?php
/* Smarty version 3.1.31, created on 2019-07-30 23:55:46
  from "/www/wwwroot/phprap/application/admin/view/db/index.html" */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '3.1.31',
  'unifunc' => 'content_5d40688249fe96_11840140',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    'ec020695ba85b9532ea30f91a82195df3a450703' => 
    array (
      0 => '/www/wwwroot/phprap/application/admin/view/db/index.html',
      1 => 1564463076,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_5d40688249fe96_11840140 (Smarty_Internal_Template $_smarty_tpl) {
if (!is_callable('smarty_function_include_file')) require_once '/www/wwwroot/phprap/application/common/smarty/function.include_file.php';
echo smarty_function_include_file(array('name'=>'public/header','title'=>'数据库备份/还原'),$_smarty_tpl);?>

<style>
    .table {
        width: 100%;
        max-width: 100%;
        margin-bottom: 0;
    }
</style>
</head>

<body>

<div id="wrapper">

    <!-- Navigation -->
    <?php echo smarty_function_include_file(array('name'=>'public/nav','sidebar'=>'sidebar'),$_smarty_tpl);?>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <div class="page-header">
                    <h1>数据库备份 </h1>
                    <div class="opt-btn">
                        <a href="javascript:void(0);" class="btn btn-sm btn-warning js_backupBtn" data-placement="bottom" data-id="26">备份</a>
                    </div>
                </div>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->

        <div class="row">
            <div class="col-sm-12">
                <div class="panel panel-default">

                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>#</th>
                                    <th>文件名</th>
                                    <th>文件大小</th>
                                    <th>备份时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>

                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['dbbaks']->value, 'dbbak', false, 'k');
if ($_from !== null) {
foreach ($_from as $_smarty_tpl->tpl_vars['k']->value => $_smarty_tpl->tpl_vars['dbbak']->value) {
?>

                                <tr>
                                    <td><?php echo $_smarty_tpl->tpl_vars['k']->value+1;?>
</td>
                                    <td><?php echo $_smarty_tpl->tpl_vars['dbbak']->value['file'];?>
</td>
                                    <td><?php echo $_smarty_tpl->tpl_vars['dbbak']->value['size'];?>
KB</td>
                                    <td><?php echo $_smarty_tpl->tpl_vars['dbbak']->value['add_time'];?>
</td>
                                    <td style="width: 25%;">
                                        <a href="<?php echo url("admin/db/download");?>
?id=<?php echo $_smarty_tpl->tpl_vars['dbbak']->value['id'];?>
" class="btn btn-warning btn-xs" data-id="<?php echo $_smarty_tpl->tpl_vars['dbbak']->value['id'];?>
">下载文件</a>
                                        <button type="button" class="btn btn-danger btn-xs js_deleteBtn" data-id="<?php echo $_smarty_tpl->tpl_vars['dbbak']->value['id'];?>
">删除文件</button>
                                        <button type="button" class="btn btn-success btn-xs js_restoreBtn" data-id="<?php echo $_smarty_tpl->tpl_vars['dbbak']->value['id'];?>
">还原数据</button>
                                    </td>
                                </tr>

                                <?php
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);
?>

                                </tbody>
                            </table>
                        </div>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.panel-body -->
                </div>
            </div>
            <!-- /.panel -->
            <div class="col-sm-12">
                <?php echo smarty_function_include_file(array('name'=>'public/page'),$_smarty_tpl);?>

            </div>
        </div>

        <!-- 还原模态框 -->
        <div class="modal fade" id="js_restoreDbModal" tabindex="-9" role="dialog">
            <div class="modal-dialog" role="document">

                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">还原数据</h4>
                    </div>
                    <div class="modal-body">

                        <iframe id="js_restoreDbIframe" style="min-height: 450px;" src="<?php echo url('admin/db/restore');?>
"></iframe>

                    </div>

                </div>

            </div>

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <hr>
    <p class="text-center"><?php echo get_config('copyright');?>
</p>
    <?php echo '<script'; ?>
>
        $(function () {
            // 备份
            $(".js_backupBtn").click(function () {
                var url = "<?php echo url('admin/db/backup');?>
";
                $.post(url, {}, function(json){

                    alert(json.msg, 1000, function(){

                        window.location.reload();

                    });

                }, 'json');
            });
            // 删除文件
            $(".js_deleteBtn").click(function () {
                var thisObj = $(this);
                var url = "<?php echo url('admin/db/delete');?>
";
                var id  = thisObj.data('id');

                confirm('确认要删除备份文件?', function(){

                    $.post(url, { id:id }, function(json){

                        if(json.code == 200){

                            alert(json.msg, 500, function () {
                                thisObj.closest('tr').remove();
                            });

                        }else{

                            alert(json.msg, 2000);

                        }

                    }, 'json');
                });

            });

            // 还原数据
            $(".js_restoreBtn").click(function () {

                var thisObj       = $(this);
                var restoreModal  = $("#js_restoreDbModal");

                var iframeSrc     = "<?php echo url('admin/db/restore');?>
" + "?id=" + thisObj.data('id');

                confirm('确认要将数据还原?', function(){

                    restoreModal.find('iframe').attr('src', iframeSrc);

                    setTimeout(function () {
                        restoreModal.modal('show');
                    }, 200);

                });

            });
        });
    <?php echo '</script'; ?>
>
    <?php echo smarty_function_include_file(array('name'=>'public/footer'),$_smarty_tpl);?>

<?php }
}
